GH-49268: [C++][FlightRPC] Fix ODBC tests for MacOS#49267
Conversation
|
Thanks for opening a pull request! If this is not a minor PR. Could you open an issue for this pull request on GitHub? https://github.com/apache/arrow/issues/new/choose Opening GitHub issues ahead of time contributes to the Openness of the Apache Arrow project. Then could you also rename the pull request title in the following format? or See also: |
|
|
53d0e44 to
af8035e
Compare
| ValidateFetch(stmt, SQL_NO_DATA); | ||
|
|
||
| // Sizes are zeros | ||
| EXPECT_EQ(SQL_SUCCESS, SQLColumns(this->stmt, catalog_name, 0, schema_name, 0, |
There was a problem hiding this comment.
Note to reviewers: many of the PR's changes for removing this->
Co-authored-by: justing-bq <justin.gossett@improving.com> Co-authored-by: alinalibq <alina.li@improving.com> Update test files Refactor test setup/teardown to reuse connection across tests * Define Mock Server SetUp/TearDown at Environment level * Refactor test setup/teardown to reuse connection across tests * In-progress fix DSN write issue on macOS without `sudo` * Getting errors of `SQLSetConfigMode` flagged as `void`, ``` error: cannot initialize return object of type 'bool' with an rvalue of type 'void' 502 | ASSERT_TRUE(SQLSetConfigMode(ODBC_BOTH_DSN)); ``` * Clean Up PR * Remove unneeded changes --------- Co-Authored-By: Alina (Xi) Li <alinal@bitquilltech.com>
Put `ODBCINST` before `ODBC_LIBRARIES` in terms of linking. Co-Authored-By: Alina (Xi) Li <alinal@bitquilltech.com>
* Enable disabled tests * Fix getinfo tests to use standalone connection
kou
left a comment
There was a problem hiding this comment.
Could you check the "ODBC Windows" CI failure?
https://github.com/apache/arrow/actions/runs/22965712197/job/66668619896?pr=49267
| L"Error during utf8 to wide string conversion"); | ||
|
|
||
| PostError(ODBC_ERROR_GENERAL_ERR, werror_msg.c_str()); | ||
| PostError(ODBC_ERROR_GENERAL_ERR, (LPWSTR)werror_msg.c_str()); |
There was a problem hiding this comment.
Could you use C++ style cast instead of C style cast in C++?
There was a problem hiding this comment.
Now using const_cast
There was a problem hiding this comment.
Pull request overview
This PR aims to make the Arrow Flight SQL ODBC test suite pass on macOS (iODBC) by restructuring test setup/teardown (mock server + connection lifecycle), adjusting platform-specific expectations, and enabling the ODBC tests to run in macOS CI.
Changes:
- Reworked ODBC test fixtures to share global ODBC handles and move connection/setup logic to test-suite scope (plus added a global mock-server test environment).
- Adjusted/disabled tests and expectations for iODBC/macOS differences (SQL states, unsupported APIs).
- Updated DSN/system-DSN plumbing and macOS CI permissions so DSN-based tests can run.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| cpp/src/arrow/flight/sql/odbc/tests/type_info_test.cc | Refactors handle usage and adds macOS-specific behavior for ODBC v2 type-info cases. |
| cpp/src/arrow/flight/sql/odbc/tests/tables_test.cc | Updates tests to use shared statement handle pattern; adds explicit table cleanup. |
| cpp/src/arrow/flight/sql/odbc/tests/statement_attr_test.cc | Improves error assertions; enables/updates statement attribute tests. |
| cpp/src/arrow/flight/sql/odbc/tests/odbc_test_suite.h | Introduces shared global handles/state and macOS buffer sizing; refactors fixture APIs to static helpers. |
| cpp/src/arrow/flight/sql/odbc/tests/odbc_test_suite.cc | Adds global mock server environment; refactors connect/disconnect lifecycle; enables DSN write helpers on more platforms. |
| cpp/src/arrow/flight/sql/odbc/tests/get_functions_test.cc | Disables SQLGetFunctions tests on macOS/iODBC. |
| cpp/src/arrow/flight/sql/odbc/tests/errors_test.cc | Updates tests to use shared handles and macOS-specific behavior. |
| cpp/src/arrow/flight/sql/odbc/tests/connection_test.cc | Updates tests to use shared handles; enables DSN-based connection tests beyond Windows. |
| cpp/src/arrow/flight/sql/odbc/tests/connection_info_test.cc | Adjusts expected values for macOS DM; adds handle-only variants for inconsistent DM behavior. |
| cpp/src/arrow/flight/sql/odbc/tests/connection_attr_test.cc | Adds macOS/iODBC-specific expectations and disables tracing-related cases on macOS. |
| cpp/src/arrow/flight/sql/odbc/tests/CMakeLists.txt | Adjusts link order to prefer iODBC on macOS. |
| cpp/src/arrow/flight/sql/odbc/odbc_impl/win_system_dsn.cc | Updates PostError call signature usage. |
| cpp/src/arrow/flight/sql/odbc/odbc_impl/system_dsn.h | Moves DSN API into shared impl headers; adjusts PostError signature; adds odbcinst include. |
| cpp/src/arrow/flight/sql/odbc/odbc_impl/system_dsn.cc | Makes DSN registration helpers build cross-platform; changes PostError signature/behavior. |
| cpp/src/arrow/flight/sql/odbc/odbc_impl/odbc_statement.cc | Avoids descriptor null deref when setting APD/ARD attrs. |
| cpp/src/arrow/flight/sql/odbc/odbc_impl/CMakeLists.txt | Builds system_dsn.{cc,h} as part of core ODBC impl library. |
| cpp/src/arrow/flight/sql/example/sqlite_tables_schema_batch_reader.cc | Improves schema-reading logic by mapping columns per table in a single SQLite scan. |
| ci/scripts/cpp_test.sh | Stops excluding the Flight SQL ODBC test binary on macOS. |
| .github/workflows/cpp_extra.yml | Grants macOS CI write permission to system DSN location. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| @@ -42,7 +38,7 @@ void PostArrowUtilError(arrow::Status error_status) { | |||
| std::wstring werror_msg = arrow::util::UTF8ToWideString(error_msg).ValueOr( | |||
| L"Error during utf8 to wide string conversion"); | |||
|
|
|||
| PostError(ODBC_ERROR_GENERAL_ERR, werror_msg.c_str()); | |||
| PostError(ODBC_ERROR_GENERAL_ERR, (LPWSTR)werror_msg.c_str()); | |||
| } | |||
|
|
|||
| void PostLastInstallerError() { | |||
| @@ -55,7 +51,7 @@ void PostLastInstallerError() { | |||
| buf << L"Message: \"" << msg << L"\", Code: " << code; | |||
| std::wstring error_msg = buf.str(); | |||
|
|
|||
| PostError(code, error_msg.c_str()); | |||
| PostError(code, (LPWSTR)error_msg.c_str()); | |||
| } | |||
There was a problem hiding this comment.
PostError/callers cast away constness from std::wstring::c_str() to pass an LPWSTR. If the installer API ever writes into this buffer, that becomes undefined behavior. Prefer keeping the parameter const (e.g., LPCWSTR) when possible, or pass a truly mutable, null-terminated buffer (e.g., std::vector<wchar_t> / std::wstring with data() in C++17+ and ensuring null termination) instead of casting.
There was a problem hiding this comment.
Now using const_cast.
| TEST_F(TypeInfoOdbcV2MockTest, TestSQLGetTypeInfoSQLTypeTimeODBCVer2) { | ||
| TEST_F(TypeInfoOdbcV2MockTest, TestSQLGetTypeInfoSQLTypeTime) { | ||
| #ifdef __APPLE__ | ||
| ASSERT_EQ(SQL_SUCCESS, SQLGetTypeInfo(stmt, SQL_TYPE_DATE)); |
There was a problem hiding this comment.
On macOS branch of TestSQLGetTypeInfoSQLTypeTime, the test calls SQLGetTypeInfo with SQL_TYPE_DATE instead of SQL_TYPE_TIME, so it isn't actually exercising the time type and will give misleading coverage/results. Update the argument to match the test name/intent.
| ASSERT_EQ(SQL_SUCCESS, SQLGetTypeInfo(stmt, SQL_TYPE_DATE)); | |
| ASSERT_EQ(SQL_SUCCESS, SQLGetTypeInfo(stmt, SQL_TYPE_TIME)); |
| #include "arrow/flight/sql/odbc/odbc_impl/util.h" | ||
| #include "arrow/result.h" | ||
| #include "arrow/util/utf8.h" | ||
|
|
There was a problem hiding this comment.
system_dsn.cc uses boost::iequals in RegisterDsn(...) but the Boost predicate header is no longer included after this change, which will break compilation. Add the appropriate Boost include (e.g., the predicate header) in this file or in a header that guarantees it for all build targets.
| #include <boost/algorithm/string/predicate.hpp> |
There is an issue for this: #49465. I think arrow-flight-test (Timeout) failure is caught on MSVC Windows platform, and I think it is not likely caused by ODBC-related changes as we haven't modified the Flight code. |
Oh, sorry. I missed it. |
|
After merging your PR, Conbench analyzed the 3 benchmarking runs that have been run so far on merge-commit 21a2d4f. There were no benchmark performance regressions. 🎉 The full Conbench report has more details. It also includes information about 2 possible false positives for unstable benchmarks that are known to sometimes produce them. |
Rationale for this change
Addresses #49268
What changes are included in this PR?
Are these changes tested?
Yes.
Are there any user-facing changes?
No.